import threading
from time import sleep

def consumer(name):
    print('{}开始'.format(name))
    for i in range(3):
        sleep(1)
        print('--------1.{}--------'.format(i))
    print('{}结束'.format(name))


def producer(name):
    print('{}开始'.format(name))
    for i in range(3):
        sleep(1)
        print('--------2.{}--------'.format(i))
    print('{}结束'.format(name))


if __name__ == '__main__':
    t1=threading.Thread(target=producer,args=(1,))
    t2 = threading.Thread(target=consumer, args=(2,))

    t1.start()
    t2.start()
''''
1开始
2开始
--------1.0--------
--------2.0--------
--------2.1--------
--------1.1--------
--------1.2--------
--------2.2--------
2结束
1结束
'''